﻿using System.Collections.Generic;
using System.Windows.Automation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIToolTipTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetToolTip()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var button = window.UIButton("@AutomationId='button1'"); 
            button.MouseHover();
            var toolTip = window.UIToolTip();
            Assert.AreEqual("Test Tooltip", toolTip.Name);
        }

        [TestMethod]
        public void ShouldGetDocumentRange()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var button = window.UIButton("@AutomationId='button1'");
            button.MouseHover();
            var toolTip = window.UIToolTip();
            Assert.IsNull(toolTip.DocumentRange);
        }

        [TestMethod]
        public void ShouldGetSupportedTextSelection()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var button = window.UIButton("@AutomationId='button1'");
            button.MouseHover();
            var toolTip = window.UIToolTip();
            Assert.AreEqual(SupportedTextSelection.None, toolTip.SupportedTextSelection);
        }

        [TestMethod]
        public void ShouldGetAllToolTips()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var button = window.UIButton("@AutomationId='button1'");
            button.MouseHover();
            System.Threading.Thread.Sleep(1000);
            List<UIToolTip> toolTips = window.UIToolTips(); 
            Assert.AreEqual(1, toolTips.Count);
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}